﻿
@{
    ViewBag.Title = "LawDocumentPageList";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css{
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <style>
        .bg-light th {
            font-weight: bolder;
        }

        .imoon {
            font-size: 18px;
            color: rgb(59,175,218);
            vertical-align: middle;
            line-height: 2;
        }

        .filename {
            font-size: 14px;
            vertical-align: middle;
            color: grey;
            cursor: pointer;
            margin: 5px;
        }

        a {
            cursor: pointer;
        }

        .userlist th {
            text-align: center;
        }
        .userlist td {
            text-align: center;
        }
    </style>
}
<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a>所有文件</a>
            </li>
            <li class="crumb-trail">控制文件</li>
        </ol>
    </div>
</header>
<section id="content" class="animated fadeIn" ng-cloak ng-controller="DocumentController" ng-init="SearchModel={};Id='@(Request.QueryString["Id"].IsEmpty() ? null : Request.QueryString["Id"])';CurrentCategoryId = 0;GetDocumentList(CurrentCategoryId);">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg">正在加载</div>
        </div>
    </div>
    <form class="form-horizontal">

        <div class="panel panel-info">
            <div class="panel-menu p12 admin-form theme-primary">
                <div class="row">
                    <div class="col-md-5">
                        <a data-toggle="modal" href="#SearchFileModal"><input type="text" class="form-control" placeholder="搜索文件..." /></a>
                    </div>
                    <div class="widget-menu pull-right" style="margin:10px;">
                        <div class="btn-group" ng-show="@ViewBag.IsModify=='1' || (RoleInfo!=null && (RoleInfo.IsManage || RoleInfo.IsAdmin))">
                            <a class="btn btn-xs btn-primary" data-toggle="modal" href="#NewFolderModal" ng-click="InitCreateFolder(Folder);">
                                <span class="glyphicons glyphicons-folder_new fs11 mr5"></span>新建文件夹
                            </a>
                        </div>
                        <div class="btn-group" ng-show="(CurrentCategoryId!=0 && RoleInfo!=null)||@ViewBag.IsModify=='1' ">
                            <button type="button" class="btn btn-xs btn-success fileinput-remove fileinput-remove-button" data-toggle="modal" href="#NewFileModal" onclick="ClearFile();">
                                <span class="glyphicons glyphicons-file_import mr5"></span>上传文件
                            </button>
                        </div>
                    </div>
                </div>

            </div>
            <div class="panel-body pn">
                <div style="margin:5px;">
                    <ol class="breadcrumb">
                        <li ng-cloak class="crumb-trail" ng-repeat="x in NavList"><a style="color:gray;cursor:pointer;font-size:15px;text-decoration:underline;color:cornflowerblue;" ng-click="GetDocumentList(x.Id);"><b>{{x.Name}}</b></a></li>
                    </ol>
                </div>
                <table class="table admin-form theme-warning tc-checkbox-1 fs13">
                    <thead>
                        <tr class="bg-light">
                            <th style="width:62%;">名称</th>
                            <th style="width:10%;">创建者</th>
                            <th style="width:10%;">更新时间</th>
                            <th style="width:10%;">大小</th>
                            <th style="width:8%;"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-show="DocumentList.length==0 && !DataLoading">
                            <td colspan="12" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                        </tr>
                        <tr ng-repeat="x in DocumentList">
                            <td style="text-align:left;cursor:pointer;" ng-click="GetCategory(x.Id,x.Type);"><span class="{{x.Icon}}"></span> <font ng-if="x.Type=='Folder'" class="filename" ng-click="GetCategory(x.Id,x.Type);">{{x.Name}}</font><a ng-if="x.Type=='File'" style="color:grey;text-decoration:none;" href="../Download/DownloadFile?FileId={{x.Id}}">{{x.Name}}{{x.Extension}}</a></td>
                            <td>{{x.CreateUser}}</td>
                            <td>{{x.UpdateTime}}</td>
                            <td>
                                {{x.Size}}
                            </td>
                            <td>
                                <div class="btn-group" ng-if="@ViewBag.IsModify=='1'|| @ViewBag.IsDelete=='1' || (x.Role!=null && (x.Role.IsManage||x.Role.IsAdmin)) || x.CreateUserNo==User.UserNo ">
                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                        操作
                                        <span class="caret ml5"></span>
                                    </button>
                                    <ul class="dropdown-menu" role="menu">
                                        <li ng-show="(@ViewBag.IsModify=='1' || (x.Role!=null && (x.Role.IsAdmin))) && x.Type=='Folder'">
                                            <a style="cursor:pointer;" data-toggle="modal" href="#RoleModal" ng-click="InitRoleConfig(x);">权限管理</a>
                                        </li>
                                        <li ng-if="@ViewBag.IsModify=='1' || (x.Role!=null && (x.Role.IsManage||x.Role.IsAdmin))">
                                            <a style="cursor:pointer;" ng-click="ShowRenameForm(x);" data-toggle="modal" href="#ReNameModal">重命名</a>
                                        </li>
                                        <li ng-if="x.Type=='File'">
                                            <a href="../Download/DownloadFile?FileId={{x.Id}}">下载</a>
                                        </li>
                                        <li ng-if="@ViewBag.IsDelete=='1' || (x.Role!=null && (x.Role.IsManage||x.Role.IsAdmin))" class="divider"></li>
                                        <li ng-if="@ViewBag.IsDelete=='1' || (x.Role!=null && (x.Role.IsManage||x.Role.IsAdmin)) || x.CreateUserNo==User.UserNo">
                                            <a ng-click="DeleteFileOrCategory(x);">删除</a>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                        </tr>

                    </tbody>
                </table>
            </div>
        </div>
    </form>
    <div class="modal fade" id="SearchFileModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">搜索文件/文件夹</h2>
                </div>
                <div class="modal-body" style="max-height:700px;overflow-y:scroll;">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">文件/目录名称</label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="" ng-model="SearchModel.Name" />
                            </div>
                            <div class="col-lg-1">
                                <button type="button" class="btn btn-primary" ng-click="SearchFile(SearchModel.Name);">   <span class="fa fa-search"></span> 搜索</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">搜索结果</label>
                            <div class="col-lg-10">
                                <table class="table admin-form theme-warning tc-checkbox-1 fs13">
                                    <tbody>
                                        <tr ng-show="ResultList.length==0 && !DataLoading">
                                            <td colspan="12" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                        </tr>
                                        <tr ng-repeat="x in ResultList">
                                            <td style="text-align:left;cursor:pointer;">
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <span class="{{x.Icon}}"></span>
                                                        <font data-dismiss="modal" ng-if="x.Type=='Folder'" class="filename" ng-click="GetCategory(x.Id,x.Type);">{{x.Name}}</font>
                                                        <a ng-if="x.Type=='File'" style="color:grey;text-decoration:none;" href="../Download/DownloadFile?FileId={{x.Id}}">{{x.Name}}{{x.Extension}}</a>
                                                    </div>

                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <span class="fa fa-folder-open" style="color:orange"></span> {{x.Path}}
                                                    </div>
                                                </div>
                                            </td>
                                            <td>{{x.CreateUser}}</td>
                                            <td>{{x.UpdateTime}}</td>
                                            <td>
                                                <button type="button" class="btn btn-primary btn-xs" ng-show="x.Type=='File'" ng-click="GetCategory(x.Id,x.Type);">下载</button>
                                                <button type="button" class="btn btn-primary btn-xs" ng-show="x.Type=='Folder'" data-dismiss="modal" ng-click="GetCategory(x.Id,x.Type);">打开</button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="NewFolderModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">新建文件夹</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">文件夹名称</label>
                            <div class="col-lg-3">
                                <input type="text" class="form-control" placeholder="必填项" maxlength="20" ng-model="Folder.CategoryName" />
                            </div>
                            <div class="col-lg-1">
                                <label class="control-label">{{20-Folder.CategoryName.length}}/20</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">是否公开</label>
                            <div class="col-lg-3">
                                <label class="checkbox-inline mr10">
                                    <input type="radio" id="yes" value="1" name="file_role"> 是
                                </label>
                                <label class="checkbox-inline mr10">
                                    <input type="radio" id="no" value="2" name="file_role" checked> 否
                                </label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="AddDocumentCategory(Folder.CategoryName,CurrentCategoryId);">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="NewFileModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">上传文件</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">添加文件</label>
                            <div class="col-lg-8">
                                <input type="file" ngf-select ng-model="doc.Files" name="docfiles" id="docfiles" class="file" initialPreviewAsData="true" data-show-remove="true" data-show-preview="true" showCancel="true" data-show-upload="false" multiple>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="UploadDocument(CurrentCategoryId);">上传</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="ReNameModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">重命名</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">名称</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" placeholder="" maxlength="50" ng-model="ReNameModel.Name" />
                            </div>
                            <div class="col-lg-1">
                                <label class="control-label">{{50-ReNameModel.Name.length}}/50</label>
                            </div>
                        </div>

                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="UpdateFileName(ReNameModel);">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="RoleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" ng-init="Role.IsPublic=0;">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">权限配置</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">是否公开</label>
                            <div class="col-lg-4">
                                <label class="checkbox-inline mr10">
                                    <input type="radio" id="yes" value="1" name="file_role" ng-click="Role.IsPublic=true" ng-checked="Role.IsPublic"> 是
                                </label>
                                <label class="checkbox-inline mr10">
                                    <input type="radio" id="no" value="2" name="file_role" ng-click="Role.IsPublic=false" ng-checked="!Role.IsPublic"> 否
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">部门</label>
                            <div class="col-lg-4">
                                <select class="form-control selectpicker" id="select_dep" ng-model="Role.DepartmentId" noneSelectedText="所有部门" ng-change="GetUserListByDepartment(Role.DepartmentId);refreshOption('select_dep');">
                                    <option ng-repeat="x in DepartmentList" value="{{x.Id}}">{{x.DepartmentName}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">权限</label>
                            <div class="col-lg-8">
                                <table class="table userlist">
                                    <thead>
                                        <tr>
                                            <th>工号</th>
                                            <th>姓名</th>
                                            <th>角色分配权限</th>
                                            <th>管理权限</th>
                                            <th>浏览权限</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-show="UserList==null || UserList.length==0">
                                            <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                        </tr>
                                        <tr ng-repeat="x in UserList">
                                            <td>{{x.UserNo}}</td>
                                            <td>{{x.UserName}}</td>
                                            <td><input type="radio" id="role_{{x.UserNo}}" name="item_{{x.UserNo}}" value="1"/></td>
                                            <td><input type="radio" id="admin_{{x.UserNo}}"  name="item_{{x.UserNo}}" value="2"/></td>
                                            <td><input type="radio" id="view_{{x.UserNo}}"  name="item_{{x.UserNo}}" value="3"/></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputStandard" class="col-lg-2 control-label">已有权限</label>
                            <div class="col-lg-8">
                                <table class="table userlist">
                                    <thead>
                                        <tr>
                                            <th>工号</th>
                                            <th>姓名</th>
                                            <th>部门</th>
                                            <th>角色分配权限</th>
                                            <th>管理权限</th>
                                            <th>浏览权限</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-show="UserRoleList.length==0 && !DataLoading">
                                            <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                        </tr>
                                        <tr ng-repeat="x in UserRoleList">
                                            <td>{{x.UserNo}}</td>
                                            <td>{{x.UserName}}</td>
                                            <td>{{x.DepartmentName}}</td>
                                            <td><span style="color:green;" ng-show="x.IsAdmin">√</span><span style="color:red;" ng-show="!x.IsAdmin">×</span></td>
                                            <td><span style="color:green;" ng-show="x.IsManage">√</span><span style="color:red;"  ng-show="!x.IsManage">×</span></td>
                                            <td><span style="color:green;" ng-show="x.IsView">√</span><span style="color:red;"  ng-show="!x.IsView">×</span></td>
                                            <td><button class="btn btn-danger btn-xs" ng-click="DeleteUserRole(x);"><span class="fa fa-trash" ></span> 移除</button></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" ng-click="SaveUserCategoryRole();">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close3">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</section>

@section Js{
    <script src="~/bussiness/js/pg/Document.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/bussiness/js/libs/moment.min.js"></script>
    <script src="~/bussiness/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/bussiness/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/bussiness/js/libs/angularjs-datepicker.js"></script>
    <script src="~/bussiness/js/libs/fileinput.js"></script>
    <script src="~/bussiness/js/libs/zh.js"></script>
    <script>
        InitFileUpload();
        function InitFileUpload() {
            $('#docfiles').fileinput({
                language: 'zh'
            });
        }

        function ClearFile() {
            $('#docfiles').fileinput('clear');
        }

        $(".selectpicker").selectpicker({
            noneSelectedText: "请选择部门"
        });
    </script>
}


